//ACCEPTED
#include <cstdio>
#include <cstring>
#include <cstdlib>


char s[101];

void process(){
	scanf("%s", s);
	int t = strlen(s);
	
	if(t>10){
		printf("%c%d%c\n",s[0],t-2,s[t-1]);
	}
	else printf("%s\n",s);
	
}

int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n;
	scanf("%d", &n);
	while(n--){
		process();
	}
	return 0;
}
